using System;
using System.Collections.Generic;
namespace HKB.Web
{
	public class AdUploadFileComparer : IComparer<AdUploadFile>
	{
		private string _sortColumn;
		private bool _reverse;
		public AdUploadFileComparer(string sortExpression)
		{
			try
			{
				this._reverse = sortExpression.ToLowerInvariant().EndsWith("desc");
			}
			catch
			{
			}
			if (this._reverse)
			{
				this._sortColumn = sortExpression.Substring(0, sortExpression.Length - 5);
			}
			else
			{
				this._sortColumn = sortExpression;
			}
		}
		public int Compare(AdUploadFile a, AdUploadFile b)
		{
			int num = 0;
			string sortColumn = this._sortColumn;
			if (sortColumn != null)
			{
				if (!(sortColumn == "FileName"))
				{
					if (!(sortColumn == "FileLoacl"))
					{
						if (!(sortColumn == "FileSize"))
						{
							if (!(sortColumn == "FileType"))
							{
								if (sortColumn == "LastAccess")
								{
									num = string.Compare(a.LastAccess, b.LastAccess);
								}
							}
							else
							{
								num = string.Compare(a.FileType, b.FileType, StringComparison.InvariantCultureIgnoreCase);
							}
						}
						else
						{
							num = string.Compare(a.FileSize, b.FileSize);
						}
					}
					else
					{
						num = string.Compare(a.FileLoacl, b.FileLoacl, StringComparison.InvariantCultureIgnoreCase);
					}
				}
				else
				{
					num = string.Compare(a.FileName, b.FileName, StringComparison.InvariantCultureIgnoreCase);
				}
			}
			return num * (this._reverse ? -1 : 1);
		}
	}
}
